package com.topscore.uke.utils;

import android.graphics.Bitmap;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.topscore.uke.R;

/**
 * Created by 71468 on 2018/3/16.
 */

public class DisplayImageOptionsManager {
    private static DisplayImageOptionsManager instance;

    public synchronized static DisplayImageOptionsManager getInstance() {
        if (instance == null) {
            instance = new DisplayImageOptionsManager();
        }
        return instance;
    }

    public DisplayImageOptions getDefaultOptions() {
        return new DisplayImageOptions.Builder()
                .showImageOnFail(R.mipmap.image_fail)
                .showImageOnLoading(R.mipmap.image_default)
                .showImageForEmptyUri(R.mipmap.image_default)
                .bitmapConfig(Bitmap.Config.ARGB_8888)
                .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
                .cacheInMemory(true)
                .cacheOnDisk(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .build();
    }

    public DisplayImageOptions getAvatarOptions() {
        return new DisplayImageOptions.Builder()
                .showImageOnFail(R.mipmap.image_fail)
                .showImageOnLoading(R.mipmap.avatar_default)
                .showImageForEmptyUri(R.mipmap.avatar_default)
                .bitmapConfig(Bitmap.Config.ARGB_8888)
                .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
                .cacheInMemory(true)
                .cacheOnDisk(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .build();
    }

    public DisplayImageOptions getOptions(int imageLoadingRes, int imageEmptyRes, int imageFailRes) {
        return new DisplayImageOptions.Builder()
                .showImageOnFail(imageFailRes)
                .showImageOnLoading(imageLoadingRes)
                .showImageForEmptyUri(imageEmptyRes)
                .bitmapConfig(Bitmap.Config.ARGB_8888)
                .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
                .cacheInMemory(true)
                .cacheOnDisk(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .build();
    }
}
